package com.net.example;

import java.io.BufferedReader;  
import java.io.IOException;  
import java.io.InputStream;  
import java.io.InputStreamReader;  
  
/* 
 * 获取局域网内所有的ip信息 
 * dos命令   arp -a 
 *  
 * java代码调用dos命令 
 * Process process = Runtime.getRuntime().exec("arp -a") 
 *  
 */  
public class IPScan4 {  
  
    public static void main(String[] args) {  
        // dos命令  
        String cmd = "arp -a";  
        try {  
            Process process = Runtime.getRuntime().exec(cmd);  
            InputStream is = process.getInputStream();  
            InputStreamReader isr = new InputStreamReader(is);  
            BufferedReader br = new BufferedReader(isr);  
            String content = br.readLine();  
            while (content != null) {  
                System.out.println(content);  
                content = br.readLine();  
            }  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
  
}
